﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using Quizz.DataRepository.Models;
using Quizz.Service.Services;

namespace Quizz.QuizzProjectService
{
    public partial class QuizzProjectService
    {
        public Menu MenuGetById(long id)
        {
            using (var service = new MenuService())
            {
                return service.GetById(id);
            }
        }

        public IList<Menu> MenuGetAllParent()
        {
            using(var service = new MenuService())
            {
                return service.GetAllParent().ToList();
            }
        }

        public IList<Menu> MenuGetChilds(long? parentId)
        {
            using(var service = new MenuService())
            {
                return service.GetChilds(parentId).ToList();
            }
        }

        public IList<Menu> MenuGetParentForRole(long role)
        {
            using(var service = new MenuService())
            {
                return service.GetParentMenuForRole(role).ToList();
            }
        }

        public IList<Menu> MenuGetChildForRole(long? parent, long role)
        {
            using(var service = new MenuService())
            {
                return service.GetChildMenuForRole(parent, role).ToList();
            }
        }

        public IList<Menu> MenuGetAllForRole(long role)
        {
            using(var service = new MenuService())
            {
                return service.GetAllForRole(role).ToList();
            }
        }

        public IList<Menu> MenuGetForAnonymous()
        {
            using(var service = new MenuService())
            {
                return service.GetMenuForAnonymous().ToList();
            }
        }

        public void MenuDelete(long id)
        {
            using(var service = new MenuService())
            {
                service.Delete(id);
            }
        }

        public void MenuInsert(Menu menu)
        {
            using(var service = new MenuService())
            {
                service.Insert(menu);
            }
        }
        
        public void MenuUpdate(Menu menu)
        {
            using(var service = new MenuService())
            {
                service.Update(menu);
            }
        }

        public Menu MenuGetByUrl(string baseUrl)
        {
            using(var service = new MenuService())
            {
                return service.GetByUrl(baseUrl);
            }
        }
    }
}